﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Xml;
using System.Collections;

namespace ConsoleApplication1
{
  public class MyList : ArrayList
    {
       public void create(string path) 
        {
            Factory.gi(path).Create(this);            
        }
       public void read(string path)
       {
           this.Clear();
           this.AddRange(Factory.gi(path).Read());          
        }
       public void update(string path, int id, string fname, string lname, int age)
       {
           Factory.gi(path).Update(id,fname,lname,age);
           read(path);
       }
       public void delete(string path, int id)
       {
           Factory.gi(path).Delete(id);
           read(path);
       }

    }
    
    class objects
    {
        static void Main(string[] args)
        {
            MyList expected = new MyList();

            expected.Add(new Person { id = 7, FName = "lal",LName="ca1",Age = 7 });            
            expected.read(@"Data Source=LUCKY;Initial Catalog=CRUD;Integrated Security=True");
            expected.create(@"c:\temp\MyTest.csv");
            /*
            MyList b = new MyList();
            b.load(@"c:\temp\MyTest.xml");
          //  b = b.load(@"c:\temp\MyTest.xml");

            foreach (items p in b)
            {
                Console.WriteLine(b[0].ToString());
            }
            expected.Clear();
            expected.load(@"c:\temp\MyTest.yaml");
            expected.save(@"c:\temp\MyTest2.yaml");
            foreach (items p in expected)
            {
                Console.WriteLine(expected[0].ToString());
            }
           Console.ReadKey();*/

        }   
    }


}
